from utils import import_module
import simplexmlapi
    
# import driver

driver = None
driver_config = None
default_driver_path = 'authDSL.drivers.DefaultDriver'
default_driver_config = None

try:

    # load configuration
    read_data = None
    with open('authDSL/config.xml', 'r') as f:
        read_data = f.read()
    f.closed
    config = simplexmlapi.loads(read_data)
    
    # load driver
    driver_path = default_driver_path if (config.driver is None or config.driver == "") else config.driver._
    driver = import_module(driver_path)
    print 'AUTH_DSL: Driver carregado:', driver_path

except:
    driver = import_module(default_driver_path)
    
# configure
is_auth = driver.Decorators.is_auth
has_group = driver.Decorators.has_group
authenticator = driver.Authentication()

